package com.发布订阅模式.第二种实现方式;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/5/28 17:01
 * @description:唐僧观察类
 * @version:
 */
@Component
public class TangShengListener implements ApplicationListener<MonkeyKingEvent> {

    @Override
    public void onApplicationEvent(MonkeyKingEvent event) {
        boolean knockGround = event.getMonkeyKing().isKnockGround();
        if (knockGround) {
            TangSheng.fly();
        } else {
            TangSheng.run();
        }
    }
}
